package com.dong.controller;

import com.dong.entity.Account;
import com.dong.entity.Orders;
import com.dong.service.IOrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
@RequestMapping("orders")
public class OrdersController {
    @Autowired
    private IOrdersService ordersService;

    //查询所有订单
    @RequestMapping("findAllOrders")
//    public ModelAndView findAllOrders(){
//        List<Orders> listOrders = ordersService.findAllOrders();
//        ModelAndView mv = new ModelAndView();
//        mv.addObject("listOrders",listOrders);
//        for (Orders o:listOrders
//             ) {
//            System.out.println(o.getO_id());
//        }
//
////        System.out.println(ordersByaid.getOrders());
//        mv.setViewName("listAllOrders");
//        return mv;
//    }

    public String findAllOrders(Model model){
        List<Orders> listOrders = ordersService.findAllOrders();
        model.addAttribute("listOrders",listOrders);
        for (Orders o:listOrders
             ) {
            System.out.println(o);
        }

//        System.out.println(ordersByaid.getOrders());

        return "listAllOrders";
    }
}
